﻿using System.Windows.Data;
using System.Windows;
using System;

namespace Tutorial
{
    /// <summary>
    /// Converts a Boolean value to FontWeight.
    /// </summary>
    public class BooleanToBoldConverter : IValueConverter
    {
        /// <summary>
        /// Converts from Boolean to FontWeight.
        /// </summary>
        /// <param name="value">The value to convert.</param>
        /// <param name="targetType">The target type.</param>
        /// <param name="parameter">Converter parameter.</param>
        /// <param name="culture">Culture for conversion.</param>
        /// <returns>The converted value.</returns>
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            // This is a really simple conversion. If the source value is true, we return FontWeights.Bold. Otherwise FontWeights.Normal.
            return (bool)value ? FontWeights.Bold : FontWeights.Normal;
        }

        /// <summary>
        /// Converts from FontWeight to Boolean.
        /// </summary>
        /// <param name="value">The value to convert.</param>
        /// <param name="targetType">The target type.</param>
        /// <param name="parameter">Converter parameter.</param>
        /// <param name="culture">Culture for conversion.</param>
        /// <returns>The converted value.</returns>
        /// <remarks>This function is not implemented and not used by the tutorial.</remarks>
        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}